How to work with variable with different datatype in Typescript